<template>
  <div class="common-layout">
    <el-container class="layout-container">
      <el-header class="layout-header">
        <div>
          <img
            :src="require('../images/logo.png')"
            style="width: 200px; height: 50px; margin-top: 5px"
            alt=""
            srcset=""
          />
          <span v-if="!isCollapse" class="header-content"
            >
            <!-- <span style="margin: 0 20px; font-size: 20px">|</span>远程超声报告服务平台V {{ versionNum }}</span> -->
            <span style="margin: 0 20px; font-size: 20px">|</span>远程超声报告服务平台</span>
        </div>
        <!-- <div>当前登录：{{ $store.getters.name }}</div> -->
        <el-dropdown style="color: #fff">
          <span class="el-dropdown-link">
            当前登录：{{ $store.getters.name }}
            <el-icon class="el-icon--right">
              <arrow-down />
            </el-icon>
          </span>
          <template #dropdown>
            <el-dropdown-menu>
              <el-dropdown-item>
                <span @click="psdEdit">密码修改</span>
              </el-dropdown-item>
              <el-dropdown-item>
                <span @click="loginOut"
                  >退&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;出</span
                >
              </el-dropdown-item>
            </el-dropdown-menu>
          </template>
        </el-dropdown>
      </el-header>
      <el-container style="height: calc(100% - 60px)">
        <el-aside :width="isCollapse ? '64px' : '250px'">
          <el-menu
            class="el-menu-vertical-demo"
            :default-active="defaultHash"
            :default-openeds="defaultOpeneds"
            mode="vertical"
            :unique-opened="false"
            :collapse-transition="false"
            :collapse="isCollapse"
            active-text-color="#fff"
            style="height: 100%"
            @select="handleSelect"
          >
            <!-- 一级菜单 -->
            <template v-for="item in tempMenu">
              <el-sub-menu
                v-if="item.children && item.children.length"
                :key="item.path"
                :index="item.path"
              >
                <template #title>
                  <!-- <el-icon>
                    <component class="icons" :is="item.icon" />
                  </el-icon> -->
                  <img
                    style="width: 16px; height: 16px; margin-right: 10px"
                    :src="item.icon"
                    alt=""
                  />
                  <!-- <i :class="item.icon" style="color:#fff" /> -->
                  <span style="padding-left: 0px">{{ item.label }}</span>
                </template>
                <!-- 二级菜单 -->
                <template v-for="itemChild in item.children">
                  <el-sub-menu
                    v-if="itemChild.children && itemChild.children.length"
                    :key="itemChild.path"
                    :index="itemChild.path"
                  >
                    <template #title
                      ><span style="padding-left: 2px">{{
                        itemChild.label
                      }}</span></template
                    >
                    <!-- 三级菜单 -->
                    <el-menu-item
                      v-for="itemChild_Child in itemChild.children"
                      :key="itemChild_Child.path"
                      :index="itemChild_Child.path"
                    >
                      <span style="padding-left: 0px">{{
                        itemChild_Child.label
                      }}</span>
                    </el-menu-item>
                  </el-sub-menu>
                  <el-menu-item
                    v-else
                    :key="itemChild.path"
                    :index="itemChild.path"
                  >
                    <span style="padding-left: 0px">{{
                      itemChild.label
                    }}</span></el-menu-item
                  >
                </template>
              </el-sub-menu>
              <el-menu-item v-else :key="item.path" :index="item.path">
                <i :class="item.icon" style="color: #fff" />
                <span style="padding-left: 0px">{{ item.label }}</span>
              </el-menu-item>
            </template>
          </el-menu>
        </el-aside>
        <el-main>
          <el-tabs
            v-model="editableTabsValue"
            closable
            class="demo-tabs"
            style="padding: 0 5px"
            @tab-click="chickTab"
            @tab-remove="removeTab"
          >
            <el-tab-pane
              v-for="item in menuTags"
              :key="item.name"
              :label="item.title"
              :name="item.name"
            >
              {{ item.content }}
            </el-tab-pane>
          </el-tabs>
          <router-view v-slot="{ Component, route }" class="route-main">
            <transition name="fade" mode="out-in">
              <div :key="route.path">
                <component :is="Component" />
              </div>
            </transition>
          </router-view>
        </el-main>
      </el-container>
    </el-container>
    <el-dialog
      title="修改密码"
      v-model="editVisible"
      width="600px"
      :close-on-press-escape="false"
      :close-on-click-modal="false"
    >
      <el-form
        ref="ruleForm"
        :model="ruleForm"
        :rules="rules"
        inline-message
        label-width="100px"
      >
        <el-form-item label="登录用户：" prop="username">
          <el-input
            v-model="ruleForm.username"
            placeholder="请输入登录用户"
            style="width: 300px"
          ></el-input>
        </el-form-item>
        <el-form-item label="新密码：" prop="initPsd">
          <el-input
            v-model="ruleForm.initPsd"
            placeholder="请输入新密码"
            show-password
            style="width: 300px"
          ></el-input>
        </el-form-item>
        <el-form-item label="确认密码：" prop="configPsd">
          <el-input
            v-model="ruleForm.configPsd"
            placeholder="请确认密码"
            show-password
            style="width: 300px"
          ></el-input>
        </el-form-item>
      </el-form>
      <template #footer>
        <span class="dialog-footer">
          <el-button type="" @click="editVisible = false">取消</el-button>
          <el-button type="primary" @click="submitPsd('ruleForm')"
            >提交</el-button
          >
        </span>
      </template>
    </el-dialog>
  </div>
</template>

<script>
import base from "@/utils/config/base";
import jsCookie from "js-cookie";
import md5 from "js-md5";
import { adminmodify } from "@/apis/user";
import { changeDetSelect } from "@/utils/tools";
export default {
  data() {
    const cInit = (rule, value, callback) => {
      if (!value) {
        callback(new Error("请输入初始密码"));
      } else {
        if (value.length > 5) {
          callback();
        } else {
          callback(new Error("最小输入六位数"));
        }
      }
    };
    const cConfig = (rule, value, callback) => {
      if (!value) {
        callback(new Error("请输入确认密码"));
      } else {
        if (value.length > 5) {
          if (this.ruleForm.initPsd == value) {
            callback();
          } else {
            callback(new Error("确认密码输入错误"));
          }
        } else {
          callback(new Error("最小输入六位数"));
        }
      }
    };
    return {
      // defaultOpeneds: ['/reportList/carotidArtery', '/reportList/echocardiography', '/reportList/otherProject', '/reportReview', '/reportStatistics', '/systemManagement', '/systemManagement/pactManagement', '/sessionInfo', '/systemManagement/hospitalManagement', ],
      screenWidth: null,
      defaultOpeneds: [],
      versionNum: "1.0.000", // 项目版本号
      editVisible: false,
      ruleForm: {
        username: "",
        initPsd: "",
        configPsd: "",
      },
      rules: {
        username: [
          { required: true, message: "请输入登录名称", trigger: "blur" },
        ],
        initPsd: [
          { required: true, message: "请输入初始密码", trigger: "blur" },
          { validator: cInit, trigger: "blur" },
        ],
        configPsd: [
          { required: true, message: "请输入确认密码", trigger: "blur" },
          { validator: cConfig, trigger: "blur" },
        ],
      },
      defaultHash:
        "/reportList/echocardiography/echCardiovascularProgramInside",
      isCollapse: false,
      editableTabsValue:
        "/reportList/echocardiography/echCardiovascularProgramInside",
      menuTags: [
        {
          name: "/reportList/echocardiography/echCardiovascularProgramInside",
          title: "颈动脉心血管项目",
        },
      ],
      tempMenu: [
        {
          path: "/reportList",
          name: "reportList",
          label: "报告列表",
          icon: require("@/images/menu1.png"),
          children: [
            // {
            // path: '/reportList/carotidArtery',
            // name: '/carotidArtery',
            // label: '超声心动图',
            // children: [{
            //     path: '/reportList/carotidArtery/carCardiovascularProgramInside',
            //     name: '/carCardiovascularProgramInside',
            //     label: '超声心血管项目',
            //     component: () => import('@/views/reportList/carotidArtery/carCardiovascularProgramInside.vue'),
            // }, {
            //     path: '/reportList/carotidArtery/carCardiovascularProgramPoint',
            //     name: '/carCardiovascularProgramPoint',
            //     label: '超声心血管项目',
            //     component: () => import('@/views/reportList/carotidArtery/carCardiovascularProgramPoint.vue'),
            // }
            // , {
            //     path: '/reportList/carotidArtery/carCerebrovascularProjectInside',
            //     name: '/carCerebrovascularProjectInside',
            //     label: '超声脑卒中项目',
            //     component: () => import('@/views/reportList/carotidArtery/carCerebrovascularProjectInside.vue'),
            // }, {
            //     path: '/reportList/carotidArtery/carCerebrovascularProjectPoint',
            //     name: '/carCerebrovascularProjectPoint',
            //     label: '超声脑卒中项目',
            //     component: () => import('@/views/reportList/carotidArtery/carCerebrovascularProjectPoint.vue'),
            // }
            //     ]
            // },
            {
              path: "/reportList/echocardiography",
              name: "/echocardiography",
              label: "颈动脉项目",
              children: [
                {
                  path: "/reportList/echocardiography/echCardiovascularProgramInside",
                  name: "/echCardiovascularProgramInside",
                  label: "颈动脉心血管项目",
                  component: () =>
                    import(
                      "@/views/reportList/echocardiography/echCardiovascularProgramInside.vue"
                    ),
                },
                {
                  path: "/reportList/echocardiography/echCardiovascularProgramPoint",
                  name: "/echCardiovascularProgramPoint",
                  label: "颈动脉心血管项目",
                  component: () =>
                    import(
                      "@/views/reportList/echocardiography/echCardiovascularProgramPoint.vue"
                    ),
                },
                {
                  path: "/reportList/echocardiography/echCerebrovascularProjectInside",
                  name: "/echCerebrovascularProjectInside",
                  label: "颈动脉脑卒中项目",
                  component: () =>
                    import(
                      "@/views/reportList/echocardiography/echCerebrovascularProjectInside.vue"
                    ),
                },
                {
                  path: "/reportList/echocardiography/echCerebrovascularProjectPoint",
                  name: "/echCerebrovascularProjectPoint",
                  label: "颈动脉脑卒中项目",
                  component: () =>
                    import(
                      "@/views/reportList/echocardiography/echCerebrovascularProjectPoint.vue"
                    ),
                },
              ],
            },
            {
              path: "/reportList/otherProject",
              name: "/otherProject",
              label: "颈动脉非国家项目",
              children: [
                {
                  path: "/reportList/otherProject/hncyPoint",
                  name: "/hncyPoint",
                  label: "河南村医项目",
                  component: () =>
                    import("@/views/reportList/otherProject/hncyPoint.vue"),
                },
                {
                  path: "/reportList/otherProject/hyPoint",
                  name: "/hyPoint",
                  label: "慧医项目",
                  component: () =>
                    import("@/views/reportList/otherProject/hyPoint.vue"),
                },
                {
                  path: "/reportList/otherProject/gjPoint",
                  name: "/gjPoint",
                  label: "筛查项目",
                  component: () =>
                    import("@/views/reportList/otherProject/gjPoint.vue"),
                },
              ],
            },
          ],
        },
        {
          path: "/reportReview",
          name: "/reportReview",
          label: "报告审核",
          icon: require("@/images/menu2.png"),
          children: [
            {
              path: "/reportReview/carotidArtery",
              name: "/reportReview/carotidArtery",
              label: "超声心动图",
              component: () => import("@/views/reportReview/carotidArtery"),
            },
            {
              path: "/reportReview/echocardiography",
              name: "/reportReview/echocardiography",
              label: "颈动脉",
              component: () => import("@/views/reportReview/echocardiography"),
            },
          ],
        },
        // {
        //   path: "/reportStatistics",
        //   name: "reportStatistics",
        //   label: "报告统计",
        //   icon: require("@/images/menu3.png"),
        //   children: [
        //     {
        //       path: "/reportStatistics/reportAudit",
        //       name: "reportAudit",
        //       label: "审核类",
        //       component: () => import("@/views/reportStatistics/reportAudit"),
        //     },
        //     {
        //       path: "/reportStatistics/reportNonAudit",
        //       name: "reportNonAudit",
        //       label: "非审核类",
        //       component: () =>
        //         import("@/views/reportStatistics/reportNonAudit"),
        //     },
        //   ],
        // },
        {
          path: "/statisticalAnalysis",
          name: "statisticalAnalysis",
          label: "统计分析",
          icon: require("@/images/menu3.png"),
          children: [
            {
              path: "/statisticalAnalysis/screeningSituation",
              name: "screeningSituation",
              label: "筛查情况",
              component: () =>
                import("@/views/reportStatistics/screeningSituation"),
            },
            {
              path: "/statisticalAnalysis/operationSituation",
              name: "operationSituation",
              label: "运营情况看板",
              component: () =>
                import("@/views/reportStatistics/operationSituation"),
            },
            {
              path: "/statisticalAnalysis/reportStatistics",
              name: "reportStatistics",
              label: "报告统计",
              children: [
                {
                  path: "/statisticalAnalysis/reportStatistics/reportAudit",
                  name: "reportAudit",
                  label: "审核类",
                  component: () =>
                    import("@/views/reportStatistics/reportAudit"),
                },
                {
                  path: "/statisticalAnalysis/reportStatistics/reportNonAudit",
                  name: "reportNonAudit",
                  label: "非审核类",
                  component: () =>
                    import("@/views/reportStatistics/reportNonAudit"),
                },
              ],
            },
          ],
        },
        {
          path: "/sessionInfo",
          name: "sessionInfo",
          label: "场次信息",
          icon: require("@/images/menu4.png"),
          children: [
            {
              path: "/sessionInfo/huiyiProject",
              name: "huiyiProject",
              label: "场次-慧医",
              component: () => import("@/views/sessionInfo/huiyiProject"),
            },
          ],
        },
        {
          path: "/systemManagement",
          name: "systemManagement",
          label: "系统管理",
          icon: require("@/images/menu5.png"),
          children: [
            {
              path: "/systemManagement/equipmentManagement",
              name: "equipmentManagement",
              label: "设备管理",
              component: () =>
                import("@/views/systemManagement/equipmentManagement"),
            },
            {
              path: "/systemManagement/equipmentBind",
              name: "equipmentBind",
              label: "设备绑定",
              component: () =>
                import("@/views/systemManagement/equipmentBind"),
            },
            {
              path: "/systemManagement/pactManagement",
              name: "pactManagement",
              label: "合约管理",
              children: [
                {
                  path: "/systemManagement/equipmentManagement/pactAudit",
                  name: "pactAudit",
                  label: "审核类",
                  component: () =>
                    import("@/views/systemManagement/pactManagement/pactAudit"),
                },
                {
                  path: "/systemManagement/equipmentManagement/pactNonAudit",
                  name: "pactNonAudit",
                  label: "非审核类",
                  component: () =>
                    import(
                      "@/views/systemManagement/pactManagement/pactNonAudit"
                    ),
                },
              ],
            },
            // {
            //     path: '/systemManagement/projectManagement',
            //     name: 'projectManagement',
            //     label: '项目管理',
            //     component: () => import('@/views/systemManagement/projectManagement/index')
            // },
            {
              path: "/systemManagement/hospitalManagement",
              name: "hospitalManagement",
              label: "机构管理",
              children: [
                {
                  path: "/systemManagement/hospitalManagement/hospitalManagementInside",
                  name: "hospitalManagementInside",
                  label: "项目点管理",
                  component: () =>
                    import(
                      "@/views/systemManagement/hospitalManagement/hospitalManagementInside"
                    ),
                },
                {
                  path: "/systemManagement/hospitalManagement/auditHospitalManagement",
                  name: "auditHospitalManagement",
                  label: "审核机构管理",
                  component: () =>
                    import(
                      "@/views/systemManagement/hospitalManagement/auditHospitalManagement"
                    ),
                },
              ],
            },
            {
              path: "/systemManagement/userManagement",
              name: "userManagement",
              label: "用户管理",
              component: () =>
                import("@/views/systemManagement/userManagement"),
            },
          ],
        },
      ],
      tempMenuCopy: [
        {
          path: "/reportList",
          name: "reportList",
          label: "报告列表",
          icon: require("@/images/menu1.png"),
          children: [
            // {
            //     path: '/reportList/carotidArtery',
            //     name: '/carotidArtery',
            //     label: '超声心动图',
            //     children: [{
            //         path: '/reportList/carotidArtery/carCardiovascularProgramInside',
            //         name: '/carCardiovascularProgramInside',
            //         label: '超声心血管项目',
            //         component: () => import('@/views/reportList/carotidArtery/carCardiovascularProgramInside.vue'),
            //     }, {
            //         path: '/reportList/carotidArtery/carCardiovascularProgramPoint',
            //         name: '/carCardiovascularProgramPoint',
            //         label: '超声心血管项目',
            //         component: () => import('@/views/reportList/carotidArtery/carCardiovascularProgramPoint.vue'),
            //     }
            // , {
            //     path: '/reportList/carotidArtery/carCerebrovascularProjectInside',
            //     name: '/carCerebrovascularProjectInside',
            //     label: '超声脑卒中项目',
            //     component: () => import('@/views/reportList/carotidArtery/carCerebrovascularProjectInside.vue'),
            // }, {
            //     path: '/reportList/carotidArtery/carCerebrovascularProjectPoint',
            //     name: '/carCerebrovascularProjectPoint',
            //     label: '超声脑卒中项目',
            //     component: () => import('@/views/reportList/carotidArtery/carCerebrovascularProjectPoint.vue'),
            // }
            //     ]
            // },
            {
              path: "/reportList/echocardiography",
              name: "/echocardiography",
              label: "颈动脉项目",
              children: [
                {
                  path: "/reportList/echocardiography/echCardiovascularProgramInside",
                  name: "/echCardiovascularProgramInside",
                  label: "颈动脉心血管项目",
                  component: () =>
                    import(
                      "@/views/reportList/echocardiography/echCardiovascularProgramInside.vue"
                    ),
                },
                {
                  path: "/reportList/echocardiography/echCardiovascularProgramPoint",
                  name: "/echCardiovascularProgramPoint",
                  label: "颈动脉心血管项目",
                  component: () =>
                    import(
                      "@/views/reportList/echocardiography/echCardiovascularProgramPoint.vue"
                    ),
                },
                {
                  path: "/reportList/echocardiography/echCerebrovascularProjectInside",
                  name: "/echCerebrovascularProjectInside",
                  label: "颈动脉脑卒中项目",
                  component: () =>
                    import(
                      "@/views/reportList/echocardiography/echCerebrovascularProjectInside.vue"
                    ),
                },
                {
                  path: "/reportList/echocardiography/echCerebrovascularProjectPoint",
                  name: "/echCerebrovascularProjectPoint",
                  label: "颈动脉脑卒中项目",
                  component: () =>
                    import(
                      "@/views/reportList/echocardiography/echCerebrovascularProjectPoint.vue"
                    ),
                },
              ],
            },
            {
              path: "/reportList/otherProject",
              name: "/otherProject",
              label: "颈动脉非国家项目",
              children: [
                {
                  path: "/reportList/otherProject/hncyPoint",
                  name: "/hncyPoint",
                  label: "河南村医项目",
                  component: () =>
                    import("@/views/reportList/otherProject/hncyPoint.vue"),
                },
                {
                  path: "/reportList/otherProject/hyPoint",
                  name: "/hyPoint",
                  label: "慧医项目",
                  component: () =>
                    import("@/views/reportList/otherProject/hyPoint.vue"),
                },
                {
                  path: "/reportList/otherProject/gjPoint",
                  name: "/gjPoint",
                  label: "筛查项目",
                  component: () =>
                    import("@/views/reportList/otherProject/gjPoint.vue"),
                },
                {
                  path: "/reportList/otherProject/gyPoint",
                  name: "/gyPoint",
                  label: "国药爱心",
                  component: () =>
                    import("@/views/reportList/otherProject/gyPoint.vue"),
                },
                {
                  path: "/reportList/otherProject/xjbctPoint",
                  name: "/xjbctPoint",
                  label: "新疆百草堂",
                  component: () =>
                    import("@/views/reportList/otherProject/xjbctPoint.vue"),
                },
                {
                  path: "/reportList/otherProject/xxgyjyPoint",
                  name: "/xxgyjyPoint",
                  label: "心血管研究院",
                  component: () =>
                    import("@/views/reportList/otherProject/xxgyjyPoint.vue"),
                },
              ],
            },
          ],
        },
        {
          path: "/reportReview",
          name: "/reportReview",
          label: "报告审核",
          icon: "DocumentCopy",
          children: [
            {
              path: "/reportReview/carotidArtery",
              name: "/carotidArtery",
              label: "超声心动图",
              component: () => import("@/views/reportReview/carotidArtery.vue"),
            },
            {
              path: "/reportReview/echocardiography",
              name: "/echocardiography",
              label: "颈动脉",
              component: () =>
                import("@/views/reportReview/echocardiography.vue"),
            },
          ],
        },
        {
          path: "/reportDetails",
          name: "reportDetails",
          label: "报告详情",
          icon: "DocumentCopy",
          component: () => import("@/views/reportReview/reportDetails.vue"),
        },
        // {
        //   path: "/reportStatistics",
        //   name: "reportStatistics",
        //   label: "报告统计",
        //   icon: "DataAnalysis",
        //   children: [
        //     {
        //       path: "/reportStatistics/reportAudit",
        //       name: "reportAudit",
        //       label: "审核类",
        //       component: () => import("@/views/reportStatistics/reportAudit"),
        //     },
        //     {
        //       path: "/reportStatistics/reportNonAudit",
        //       name: "reportNonAudit",
        //       label: "非审核类",
        //       component: () =>
        //         import("@/views/reportStatistics/reportNonAudit"),
        //     },
        //   ],
        // },
        {
          path: "/statisticalAnalysis",
          name: "statisticalAnalysis",
          label: "统计分析",
          icon: require("@/images/menu3.png"),
          children: [
            {
              path: "/statisticalAnalysis/screeningSituation",
              name: "screeningSituation",
              label: "筛查情况",
              component: () =>
                import("@/views/reportStatistics/screeningSituation"),
            },
            {
              path: "/statisticalAnalysis/operationSituation",
              name: "operationSituation",
              label: "运营情况看板",
              component: () =>
                import("@/views/reportStatistics/operationSituation"),
            },
            {
              path: "/statisticalAnalysis/reportStatistics",
              name: "reportStatistics",
              label: "报告统计",
              children: [
                {
                  path: "/statisticalAnalysis/reportStatistics/reportAudit",
                  name: "reportAudit",
                  label: "审核类",
                  component: () =>
                    import("@/views/reportStatistics/reportAudit"),
                },
                {
                  path: "/statisticalAnalysis/reportStatistics/reportNonAudit",
                  name: "reportNonAudit",
                  label: "非审核类",
                  component: () =>
                    import("@/views/reportStatistics/reportNonAudit"),
                },
              ],
            },
          ],
        },
        {
          path: "/sessionInfo",
          name: "sessionInfo",
          label: "场次信息",
          icon: "Finished",
          children: [
            {
              path: "/sessionInfo/huiyiProject",
              name: "huiyiProject",
              label: "场次-慧医",
              component: () => import("@/views/sessionInfo/huiyiProject"),
            },
          ],
        },
        {
          path: "/systemManagement",
          name: "systemManagement",
          label: "系统管理",
          icon: "Setting",
          children: [
            {
              path: "/systemManagement/equipmentManagement",
              name: "equipmentManagement",
              label: "设备管理",
              component: () =>
                import("@/views/systemManagement/equipmentManagement"),
            },
            {
              path: "/systemManagement/equipmentBind",
              name: "equipmentBind",
              label: "设备绑定",
              component: () =>
                import("@/views/systemManagement/equipmentBind"),
            },
            // {
            //     path: '/systemManagement/projectManagement',
            //     name: 'projectManagement',
            //     label: '项目管理',
            //     component: () => import('@/views/systemManagement/projectManagement/index')
            // },
            {
              path: "/systemManagement/pactManagement",
              name: "pactManagement",
              label: "合约管理",
              children: [
                {
                  path: "/systemManagement/equipmentManagement/pactAudit",
                  name: "pactAudit",
                  label: "审核类",
                  component: () =>
                    import("@/views/systemManagement/pactManagement/pactAudit"),
                },
                {
                  path: "/systemManagement/equipmentManagement/pactNonAudit",
                  name: "pactNonAudit",
                  label: "非审核类",
                  component: () =>
                    import(
                      "@/views/systemManagement/pactManagement/pactNonAudit"
                    ),
                },
              ],
            },
            {
              path: "/systemManagement/hospitalManagement",
              name: "hospitalManagement",
              label: "机构管理",
              children: [
                {
                  path: "/systemManagement/hospitalManagement/hospitalManagementInside",
                  name: "hospitalManagementInside",
                  label: "项目点管理",
                  component: () =>
                    import(
                      "@/views/systemManagement/hospitalManagement/hospitalManagementInside"
                    ),
                },
                {
                  path: "/systemManagement/hospitalManagement/auditHospitalManagement",
                  name: "auditHospitalManagement",
                  label: "审核机构管理",
                  component: () =>
                    import(
                      "@/views/systemManagement/hospitalManagement/auditHospitalManagement"
                    ),
                },
              ],
            },
            {
              path: "/systemManagement/userManagement",
              name: "userManagement",
              label: "用户管理",
              component: () =>
                import("@/views/systemManagement/userManagement"),
            },
          ],
        },
      ],
      // 树结构
      treeData: [
        {
          label: "报告列表",
          path: "/reportList",
          name: "reportList",
          icon: require("@/images/menu1.png"),
          parentId: "0",
          id: "1",
          childrens: [
            {
              path: "/reportList/echocardiography",
              name: "/echocardiography",
              label: "颈动脉项目",
              id: "6",
              parentId: "1",
              childrens: [
                {
                  path: "/reportList/echocardiography/echCardiovascularProgramInside",
                  name: "/echCardiovascularProgramInside",
                  label: "颈动脉心血管项目(内部管理)",
                  id: "17",
                  parentId: "6",
                },
                {
                  path: "/reportList/echocardiography/echCardiovascularProgramPoint",
                  name: "/echCardiovascularProgramPoint",
                  label: "颈动脉心血管项目",
                  id: "18",
                  parentId: "6",
                },
                {
                  path: "/reportList/echocardiography/echCerebrovascularProjectInside",
                  name: "/echCerebrovascularProjectInside",
                  label: "颈动脉脑卒中项目(内部管理)",
                  id: "19",
                  parentId: "6",
                },
                {
                  path: "/reportList/echocardiography/echCerebrovascularProjectPoint",
                  name: "/echCerebrovascularProjectPoint",
                  label: "颈动脉脑卒中项目",
                  id: "20",
                  parentId: "6",
                },
              ],
            },
            {
              path: "/reportList/otherProject",
              name: "/otherProject",
              label: "颈动脉非国家项目",
              id: "7",
              parentId: "1",
              childrens: [
                {
                  path: "/reportList/otherProject/hncyPoint",
                  name: "/hncyPoint",
                  label: "河南村医项目",
                  id: "21",
                  parentId: "7",
                },
                {
                  path: "/reportList/otherProject/hyPoint",
                  name: "/hyPoint",
                  label: "慧医项目",
                  id: "22",
                  parentId: "7",
                },
                {
                  path: "/reportList/otherProject/gjPoint",
                  name: "/gjPoint",
                  label: "筛查项目",
                  id: "23",
                  parentId: "7",
                },
                {
                  path: "/reportList/otherProject/gyPoint",
                  name: "/gyPoint",
                  label: "国药爱心",
                  id: "24",
                  parentId: "7",
                },
                {
                  path: "/reportList/otherProject/xjbctPoint",
                  name: "/xjbctPoint",
                  label: "新疆百草堂",
                  id: "29",
                  parentId: "7",
                },
                {
                  path: "/reportList/otherProject/xxgyjyPoint",
                  name: "/xxgyjyPoint",
                  label: "心血管研究院",
                  id: "30",
                  parentId: "7",
                },
              ],
            },
          ],
        },
        {
          path: "/reportReview",
          name: "/reportReview",
          label: "报告审核",
          icon: require("@/images/menu2.png"),
          parentId: "0",
          id: "2",
          childrens: [
            {
              path: "/reportReview/carotidArtery",
              name: "/reportReview/carotidArtery",
              label: "超声心动图",
              id: "8",
              parentId: "2",
            },
            {
              path: "/reportReview/echocardiography",
              name: "/reportReview/echocardiography",
              label: "颈动脉",
              id: "9",
              parentId: "2",
            },
          ],
        },
        // {
        //   path: "/reportStatistics",
        //   name: "reportStatistics",
        //   label: "报告统计",
        //   icon: require("@/images/menu3.png"),
        //   parentId: "0",
        //   id: "3",
        //   childrens: [
        //     {
        //       path: "/reportStatistics/reportAudit",
        //       name: "reportAudit",
        //       label: "审核类",
        //       id: "10",
        //       parentId: "3",
        //     },
        //     {
        //       path: "/reportStatistics/reportNonAudit",
        //       name: "reportNonAudit",
        //       label: "非审核类",
        //       id: "11",
        //       parentId: "3",
        //     },
        //   ],
        // },
        {
          path: "/statisticalAnalysis",
          name: "statisticalAnalysis",
          label: "统计分析",
          icon: require("@/images/menu3.png"),
          parentId: "0",
          id: "3",
          childrens: [
            {
              path: "/statisticalAnalysis/screeningSituation",
              name: "screeningSituation",
              label: "筛查情况",
              parentId: "3",
              id: "31",
            },
            {
              path: "/statisticalAnalysis/operationSituation",
              name: "operationSituation",
              label: "运营情况看板",
              parentId: "3",
              id: "32",
            },
            {
              path: "/statisticalAnalysis/reportStatistics",
              name: "reportStatistics",
              label: "报告统计",
              parentId: "3",
              id: "33",
              childrens: [
                {
                  path: "/statisticalAnalysis/reportStatistics/reportAudit",
                  name: "reportAudit",
                  label: "审核类",
                  id: "10",
                  parentId: "33",
                },
                {
                  path: "/statisticalAnalysis/reportStatistics/reportNonAudit",
                  name: "reportNonAudit",
                  label: "非审核类",
                  id: "11",
                  parentId: "33",
                },
              ],
            },
          ],
        },
        {
          path: "/sessionInfo",
          name: "sessionInfo",
          label: "场次信息",
          icon: require("@/images/menu4.png"),
          parentId: "0",
          id: "4",
          childrens: [
            {
              path: "/sessionInfo/huiyiProject",
              name: "huiyiProject",
              label: "场次-慧医",
              id: "12",
              parentId: "4",
            },
          ],
        },
        {
          path: "/systemManagement",
          name: "systemManagement",
          label: "系统管理",
          icon: require("@/images/menu5.png"),
          parentId: "0",
          id: "5",
          childrens: [
            {
              path: "/systemManagement/equipmentManagement",
              name: "equipmentManagement",
              label: "设备管理",
              id: "13",
              parentId: "5",
            },
            {
              path: "/systemManagement/equipmentBind",
              name: "equipmentBind",
              label: "设备绑定",
              id: "34",
              parentId: "5",
            },
            {
              path: "/systemManagement/pactManagement",
              name: "pactManagement",
              label: "合约管理",
              id: "14",
              parentId: "5",
              childrens: [
                {
                  path: "/systemManagement/equipmentManagement/pactAudit",
                  name: "pactAudit",
                  label: "审核类",
                  id: "25",
                  parentId: "14",
                },
                {
                  path: "/systemManagement/equipmentManagement/pactNonAudit",
                  name: "pactNonAudit",
                  label: "非审核类",
                  id: "26",
                  parentId: "14",
                },
              ],
            },
            {
              path: "/systemManagement/hospitalManagement",
              name: "hospitalManagement",
              label: "机构管理",
              id: "15",
              parentId: "5",
              childrens: [
                {
                  path: "/systemManagement/hospitalManagement/hospitalManagementInside",
                  name: "hospitalManagementInside",
                  label: "项目点管理",
                  id: "27",
                  parentId: "15",
                },
                {
                  path: "/systemManagement/hospitalManagement/auditHospitalManagement",
                  name: "auditHospitalManagement",
                  label: "审核机构管理",
                  id: "28",
                  parentId: "15",
                },
              ],
            },
            {
              path: "/systemManagement/userManagement",
              name: "userManagement",
              label: "用户管理",
              id: "16",
              parentId: "5",
            },
          ],
        },
      ],
    };
  },
  watch: {
    "$route.path"(val) {
      this.defaultHash = val;
      this.init();
    },
    screenWidth: {
      handler: function (val) {
        if (val <= 750) {
          this.isCollapse = true;
        } else {
          this.isCollapse = false;
        }
      },
      immediate: true,
      deep: true,
    },
  },
  created() {
    this.screenWidth = document.body.clientWidth;
    this.versionNum = base.version;
    window.onresize = () => {
      return (() => {
        this.screenWidth = document.body.clientWidth;
      })();
    };
  },
  mounted() {
    this.menuTags = JSON.parse(this.$store.getters.menutags);
    this.defaultHash = this.$store.getters.defaultHash;
    let roleMenu = this.$store.getters.rolemenu
      ? this.$store.getters.rolemenu.split(",")
      : [];
    let menuArr = [];
    if (roleMenu && roleMenu.length > 0) {
      roleMenu.forEach((el) => {
        menuArr = menuArr.concat(changeDetSelect(el, this.treeData));
      });
    }
    this.tempMenu = this.dealMenu([...new Set(menuArr)]);
    this.init();
  },
  methods: {
    dealMenu(treeData) {
      if (!treeData || treeData.length == 0) {
        return [];
      }
      let res = [];
      let map = {};
      for (let v of treeData) {
        v.children = [];
        map[v.id] = v;
      }
      for (let v of treeData) {
        let parent = map[v.parentId];
        if (parent) {
          if (!parent.children) parent.children = [];
          parent.children.push(v);
        } else {
          res.push(v);
        }
      }
      return res;
    },
    submitPsd(ruleForm) {
      this.$refs[ruleForm].validate((valid) => {
        let md5Psd = "";
        if (this.ruleForm.initPsd) {
          md5Psd = md5(this.ruleForm.initPsd);
        }
        adminmodify({
          uname: this.ruleForm.username,
          upwd: md5Psd,
          rname: "",
          insname: "",
          inscode: "",
          checker: "",
        }).then((res) => {
          if (res.data.status == 0) {
            this.editVisible = false;
            this.$message({
              type: "success",
              message: "修改成功! 请退出重新登录",
            });
            this.loginOut();
          }
        });
      });
    },
    psdEdit() {
      this.ruleForm.username = "";
      this.ruleForm.initPsd = "";
      this.ruleForm.configPsd = "";
      if (this.$refs.ruleForm) {
        this.$refs.ruleForm.resetFields();
      }
      this.editVisible = true;
    },
    init() {
      // this.defaultHash = this.$route.path
      this.handleSelect(this.$route.path);
    },
    handleSelect(index) {
      let tagData = this.menuTags.filter((item) => {
        return item.name == index;
      });
      if (tagData && tagData.length > 0) {
        this.editableTabsValue = tagData[0].name;
      } else {
        this.tempMenuCopy.forEach((el) => {
          if (el.path == index) {
            this.menuTags.push({
              title: el.label,
              name: el.path,
            });
            this.editableTabsValue = el.path;
          } else {
            if (el.children && el.children.length > 0) {
              el.children.forEach((elChi) => {
                if (elChi.path == index) {
                  this.menuTags.push({
                    title: elChi.label,
                    name: elChi.path,
                  });
                  this.editableTabsValue = elChi.path;
                } else {
                  if (elChi.children && elChi.children.length > 0) {
                    elChi.children.forEach((secEl) => {
                      if (secEl.path == index) {
                        this.menuTags.push({
                          title: secEl.label,
                          name: secEl.path,
                        });
                        this.editableTabsValue = secEl.path;
                      }
                    });
                  }
                }
              });
            }
          }
        });
      }
      if (this.defaultHash != index) {
        console.log(index);
        this.$router.push(index);
      }
      this.defaultHash = index;
    },
    // 点击tab
    chickTab(tab) {
      this.$router.push(tab.props.name);
    },
    // 移除tab
    removeTab(targetName) {
      let tabs = this.menuTags;
      if (tabs && tabs.length > 1) {
        let activeName = this.editableTabsValue;
        if (activeName === targetName) {
          tabs.forEach((tab, index) => {
            if (tab.name === targetName) {
              let nextTab = tabs[index + 1] || tabs[index - 1];
              if (nextTab) {
                activeName = nextTab.name;
              }
            }
          });
        }
        this.editableTabsValue = activeName;
        this.$router.push({
          path: activeName,
        });
        this.menuTags = tabs.filter((tab) => tab.name !== targetName);
      }
    },
    // 退出
    loginOut() {
      console.log("点击了退出-----");
      jsCookie.remove("Name");
      jsCookie.remove("Insname");
      jsCookie.remove("Inscode");
      jsCookie.remove("Token");
      jsCookie.remove("Rname");
      this.$router.push("/login");
    },
  },
};
</script>

<style lang="less" scoped>
::v-deep .el-menu-item {
  padding: 0px 0px 0px 42px !important;
}
.common-layout {
  width: 100%;
  height: 100%;
  .fade-enter-active,
  .fade-leave-active {
    transition: opacity 0.5s ease;
  }
  .fade-enter-from,
  .fade-leave-to {
    opacity: 0;
  }
  .layout-container {
    height: 100%;
    .layout-header {
      border-bottom: 1px solid #eee;
      display: flex;
      justify-content: space-between;
      align-items: center;
      background: url("../images/nav.png");
      .header-content {
        display: inline-block;
        vertical-align: top;
        line-height: 60px;
        color: #fff;
      }
    }
    .el-main {
      padding: 0;
      div + div {
        height: calc(100% - 41px);
        padding: 10px;
        box-sizing: border-box;
        background-color: #eee;
        overflow-y: scroll;
      }
    }
    /deep/.el-tabs__header {
      margin: 0;
    }
    /deep/.el-tabs__content {
      height: 0;
    }
    .el-menu-item.is-active {
      background-color: #409eff !important; /* 你想要的颜色 */
    }
  }
}
</style>